import { Controller, Get, Body, Param, Put, Query, Post } from '@nestjs/common';
import { Order_Service } from './order.service';
import { Order_Find_Dto, Order_Refund_Dto, Order_Update_Dto } from './assets/order.dto';
import { ApiTags } from '@nestjs/swagger';
import { util_Index_ReturnContent } from '@/common/util/index';
import { util_ApiResponse_Base } from '@/common/util/apiResponse';

@Controller('/adm/order')
@ApiTags('order 订单管理')
export class Order_Controller {
  constructor(private readonly order_Service: Order_Service) {}

  @Get('/list')
  @util_ApiResponse_Base({
    dataType: 'dataType_list',
  })
  async order_FindByPage(@Query() query: Order_Find_Dto) {
    return util_Index_ReturnContent(await this.order_Service.order_FindByPage(query));
  }

  @Get('/detail/:id')
  @util_ApiResponse_Base({
    dataType: 'dataType_object',
  })
  async order_FindOneById(@Param('id') id: string) {
    return util_Index_ReturnContent(await this.order_Service.order_FindOneById(+id));
  }

  @Put('/update')
  @util_ApiResponse_Base({
    dataType: 'dataType_update',
  })
  async order_Update(@Body() body: Order_Update_Dto) {
    return util_Index_ReturnContent(await this.order_Service.order_Update(body));
  }

  @Post('/refund')
  @util_ApiResponse_Base({
    dataType: 'dataType_string',
    status: 201,
    description: '退款',
    type: '退款成功',
    summary: '退款',
  })
  async order_Refund(@Body() body: Order_Refund_Dto) {
    return util_Index_ReturnContent(await this.order_Service.order_Refund(body));
  }
}
